#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;

LL n;
LL q[N];

void solve(){
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> q[i];

    if(n == 2){
        LL res = max(q[1] + q[2], abs(q[1] - q[2]) * 2);
        cout << res << '\n';
    }else if(n == 3){
        LL res = max(abs(q[1] - q[2]) * 3, max(abs(q[3] - q[2]) * 3, max(q[1] * 3, max(q[3] * 3, q[1] + q[2] + q[3]))));
        cout << res << '\n';
    }else{
        LL mv = 0;
        for(int i = 1; i <= n; i ++){
            mv = max(mv, q[i]);
        }
        LL res = mv * n;
        cout << res << '\n';
    }
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        solve();
    }


    return 0;
}